import requests

from common.DBUtil import DBUtil

url = "http://ihrm-test.itheima.net/api/sys/login"
headers = {"Content-Type": "application/json"}
body = {"mobile":"13800000002","password":"123456"}
resp = requests.post(url,headers=headers,json=body)
print(resp.json())

            # print(TestLogin.test_login().get("data"))
token = "Bearer " + resp.json().get("data")
print(token)
sql = "delete from bs_user where mobile='17591081681';"
DBUtil.uid_db(sql)
url_add = "http://ihrm-test.itheima.net/api/sys/user"

headers = {"Content-Type": "application/json", "Authorization": token}
body_add = {"username": "DB01", "mobile": "17591081681", "workNumber": "123"}
            # sql = "insert into "
            # DBUtil.uid_db(sql)
resp_add = requests.post(url_add, headers=headers, json=body_add)
print(resp_add.json())
        # print(resp.json())

id = resp_add.json().get("data").get("id")
url_query = "http://ihrm-test.itheima.net/api/sys/user" + "/" + id
re = requests.get(url= url_query,headers=headers)
print(re.json())

#修改
body_modify = {"username": "DB01", "password": "123456", "departmentId": "10086"}
resp_modify = requests.put(url = url_query ,headers=headers,json=body_modify )
print(resp_modify.json())




